/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.chl.da.controllerBeans;

import edu.chl.da.ejb.core.Customer;
import edu.chl.da.ejb.core.Flight;
import edu.chl.da.ejb.ctrl.IManageReservation;
import edu.chl.da.ejb.core.Reservation;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 * Controller bean managing listing, getting and removal events of reservations
 * @author Kristofer
 */
@ManagedBean(name = "ManageReservationsBean")
@SessionScoped
public class ManageReservationsBean {

    private List<Reservation> reservations;
    private Reservation selectedReservation;



    /** Creates a new instance of ManageReservationsBean */
    @EJB
    IManageReservation imr;


    public ManageReservationsBean() {
    }

    public void listReservationsForCustomer(Customer customer) {
        this.reservations = imr.getReservations(customer);
    }

    public void listReservations(Flight flight){
        this.reservations = imr.getReservations(flight);
    }

    public void listAllReservations() {
        this.reservations = imr.getAllReservations();
    }

    public void removeReservation(){
        imr.removeReservation(selectedReservation);
    }

     public void setReservations(List<Reservation> reservations) {
        this.reservations = reservations;
    }

    public List<Reservation> getReservations() {
        return reservations;
    }

    public void setSelectedReservation(Reservation selectedReservation) {
        this.selectedReservation = selectedReservation;
    }

    public Reservation getSelectedReservation() {
        return selectedReservation;
    }
}
